# 员工管理模块的接口
import requests

import config


class IhrmEmpCURD(object):

    # 添加员工
    @classmethod
    def add_emp(cls, header, json_data):
        url = config.IHRM_URL + "/api/sys/user"
        resp = requests.post(url=url, headers=header, json=json_data)
        return resp

    # 查询员工
    @classmethod
    def query_emp(cls, emp_id, header):
        url = config.IHRM_URL + f"/api/sys/user/{emp_id}"
        resp = requests.post(url=url, headers=header)
        return resp

    # 修改员工
    @classmethod
    def modify_emp(cls, emp_id, header, json_data):
        url = config.IHRM_URL + f"/api/sys/user/{emp_id}"
        resp = requests.post(url=url, headers=header, json=json_data)
        return resp

    # 删除员工
    @classmethod
    def delete_emp(cls, emp_id, header):
        url = config.IHRM_URL + f"/api/sys/user/{emp_id}"
        resp = requests.post(url=url, headers=header)
        return resp


# if __name__ == '__main__':
#     header = {
#         "Context-Type": "application/json",
#         "Authorization": "Bearer 6ef2f06c-fc42-4212-ae9f-18780056834aa"}
#     date_add = {
#         "username": "小猪猪",
#         "mobile": "13967554163",
#         "workNumber": "9527"
#     }
#     resp = IhrmEmpCURD.add_emp(header, date_add)
#     print(resp)
#
#     emp_id = "12832238414"
#     resp = IhrmEmpCURD.query_emp(emp_id=emp_id, header=header)
#     print(resp)
#
#     data = {
#         "username": "大圣123"
#     }
#     resp = IhrmEmpCURD.modify_emp(emp_id, header, data)
#     print(resp)
#
#     resp = IhrmEmpCURD.delete_emp(emp_id, header)
#     print(resp)
